'use strict';
//事件声明器
define(['app'],function(app){
    var homeEvent = Class.extend({
        //注入服务
        setTimeout: null,

        //绑定的事件，事件是由defineListeners绑定上去的,
        //认为控制器里不应该有这些业务逻辑
        _bind1: function(){
            this.$scope.page =  {
                heading: this._data1
            };
        },

        _bind2: function(){
            //!!!
            var that = this;
            this.setTimeout(function(){
                //在setTimeout里函数this指向会变让这个this有用var that = this;
                that.$scope.page =  {
                    heading: that._data2
                };
            });
        }
    });

    (function (){

        var homeEventProvider = Class.extend({

            instance: new homeEvent(),

            $get:['$timeout',function($timeout){
                this.instance.setTimeout = $timeout;
                return this.instance;
            }]
        });

        app.provider('homeEvent',homeEventProvider);
    }());

    return homeEvent;
});